﻿using System;
using System.IO;
using System.Reflection;
using Xunit;
using myCollections.BL.Export;

namespace myCollectionsTests.BL.Export
{
    public class HtmlExportTests
    {
        private const string What = "";
        private const string FilePath = "";

        public HtmlExportTests()
        {
            new HtmlExporter(What);
        }

        //   private void ExportApps(XmlWriter xmlWriter)
        [Fact]
        public void TestConcatTheseStrings()
        {
            var result = (bool)RunStatic(typeof(HtmlExporter), "ExportApps");
            Assert.True(result);
        }

        private static object RunStatic(Type classType, string method)
        {
            var methodInfo = classType.GetMethod(method, BindingFlags.NonPublic | BindingFlags.Static);
            return methodInfo.Invoke(null, null);
        }


        [Fact]
        public void should_build_correct_html_file()
        {
//            var str = htmpExport.ConvertToHtml();
//
//            WriteToFile(str, "myCollections");
        }

        private void WriteToFile(string str, string fileName)
        {
            //this code segment write data to file.
            FileStream fs1 = new FileStream(string.Format(@"C:\Projects\exp\{0}.html", fileName), FileMode.OpenOrCreate, FileAccess.Write);
            StreamWriter writer = new StreamWriter(fs1);
            writer.Write(str);
            writer.Close();
        }
    }
}
